package MazeSolver;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.SwingUtilities;

public class MazeMouseController implements MouseListener {
	private MazeView view;
	private MazeModel model;

	public MazeMouseController(MazeView view, MazeModel model) {
		this.view = view;
		this.model = model;
	}

	@Override
	public void mouseClicked(MouseEvent me) {
		if(view.imageContainsClick(me)) {
			int x = me.getX() - view.getHorizontalOffset();
			int y = me.getY() - view.getVerticalOffset();
			
			if(SwingUtilities.isLeftMouseButton(me)) {
				model.setStart(x,y);
			} else if(SwingUtilities.isRightMouseButton(me)) {
				model.setEnd(x,y);
			} else {
				model.reset();
				model.solve();
			}
		}
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

}
